include $(AM_HOME)/scripts/isa/riscv64.mk

#AM_SRCS := riscv/npc/start.S \
#           riscv/npc/trm.c \
#           riscv/npc/ioe.c \
#           riscv/npc/timer.c \
#           riscv/npc/input.c \
#           riscv/npc/cte.c \
#           riscv/npc/trap.S \
#           platform/dummy/vme.c \
#           platform/dummy/mpe.c

 AM_SRCS :=platform/npc/ioe/ioe.c \
           platform/npc/ioe/timer.c \
           platform/npc/ioe/input.c \
					 platform/npc/ioe/gpu.c\
           platform/npc/trm.c \
           platform/npc/mpe.c\
           riscv/npc/vme.c \
           riscv/npc/cte.c \
           riscv/npc/trap.S \
				   riscv/npc/start.S 

CFLAGS    += -fdata-sections -ffunction-sections
LDFLAGS   += -T $(AM_HOME)/scripts/linker.ld --defsym=_pmem_start=0x80000000 --defsym=_entry_offset=0x0
LDFLAGS   += --gc-sections -e _start
CFLAGS += -DMAINARGS=\"$(mainargs)\"
CFLAGS += -I$(AM_HOME)/am/src/platform/npc/include
CFLAGS += -DISA_H=\"riscv/riscv.h\"
LOG = $(shell dirname $(IMAGE).elf)/npc-log.txt
.PHONY: $(AM_HOME)/am/src/riscv/npc/trm.c
BATCH = -b
#BATCH = 
image: $(IMAGE).elf
	@$(OBJDUMP) -d $(IMAGE).elf > $(IMAGE).txt
	@echo + OBJCOPY "->" $(IMAGE_REL).bin
	@$(OBJCOPY) -S --set-section-flags .bss=alloc,contents -O binary $(IMAGE).elf $(IMAGE).bin
run: image
	$(MAKE) -C $(NPC_HOME) LOG=$(LOG) ELF=$(IMAGE).elf BIN_NAME=$(IMAGE).bin BATCH=$(BATCH) run	
